package groups.common.gui;

import groups.geographics.gui.InitGeographics;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JFrame;

import javax.swing.WindowConstants;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class UserLogon extends javax.swing.JFrame {
	private JPanel topPanelEast;
	private JTextField loginInput;
	private JButton createUser;
	private JButton submit;
	private JButton deleteUser;
	private JPasswordField passkeyInput;
	private JTextPane passkey;
	private JTextPane login;
	private JPanel topPanelCenter;
	private JPanel topPanelWest;
	private Connection con;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public UserLogon(Connection con) {
		super("Login de Usu\u00E1rio");
		this.con = con;
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			{
				topPanelEast = new JPanel();
				getContentPane().add(topPanelEast, BorderLayout.EAST);
				topPanelEast.setName("topPanelEast");
				topPanelEast.setPreferredSize(new java.awt.Dimension(149, 101));
				{
					createUser = new JButton();
					topPanelEast.add(createUser);
					createUser.setName("createUser");
					createUser.setPreferredSize(new java.awt.Dimension(150, 25));
					createUser.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("createUser.actionPerformed, event="+evt);
							JFrame userCreate = new UserCreate(con);
							userCreate.setVisible(true);
						}
					});
				}
				{
					deleteUser = new JButton();
					topPanelEast.add(deleteUser);
					deleteUser.setName("deleteUser");
					deleteUser.setPreferredSize(new java.awt.Dimension(150, 25));
					deleteUser.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("deleteUser.actionPerformed, event="+evt);
							JFrame userDelete = new UserDelete(con);
							userDelete.setVisible(true);
						}
					});
				}
			}
			{
				topPanelWest = new JPanel();
				getContentPane().add(topPanelWest, BorderLayout.WEST);
				topPanelWest.setName("topPanelWest");
				topPanelWest.setPreferredSize(new java.awt.Dimension(60, 103));
				{
					login = new JTextPane();
					topPanelWest.add(login);
					login.setName("login");
				}
				{
					passkey = new JTextPane();
					topPanelWest.add(passkey);
					passkey.setName("passkey");
				}
			}
			{
				topPanelCenter = new JPanel();
				getContentPane().add(topPanelCenter, BorderLayout.CENTER);
				topPanelCenter.setName("topPanelCenter");
				topPanelCenter.setPreferredSize(new java.awt.Dimension(194, 270));
				{
					loginInput = new JTextField();
					topPanelCenter.add(loginInput);
					loginInput.setPreferredSize(new java.awt.Dimension(200, 20));
				}
				{
					passkeyInput = new JPasswordField();
					topPanelCenter.add(passkeyInput);
					passkeyInput.setPreferredSize(new java.awt.Dimension(200, 20));
				}
				{
					submit = new JButton();
					topPanelCenter.add(submit);
					submit.setName("submit");
					submit.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("submit.actionPerformed, event="+evt);
							logon();
						}
					});
				}
			}
			pack();
			this.setSize(423, 133);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private void logon(){
		JFrame initGeographics = new InitGeographics(con);
		initGeographics.setVisible(true);
		dispose();
	}

}
